package com.itheima.manager.utils;

import org.junit.Test;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.Map;
import java.util.Scanner;

public class JdbcTemplateLogin {
    //1. 获取JDBCTemplate对象
    private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());

    public static void main(String[] args) {
        login();
    }

    public static boolean login() {
        boolean flag = false;
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入工号:");
        String id = sc.next();
        System.out.println("请输入姓名:");
        String name = sc.next();
        String sql = "select * from managerman where id = ? and name = ? ";
        try {
            Map<String, Object> number = template.queryForMap(sql, id, name);
            if (number != null) {
                flag = true;
                System.out.println("========登录验证成功========");
            }
        } catch (Exception e) {
            System.out.println("========登录验证失败========");
            //e.printStackTrace();
        }

        return flag;
    }
}
